package com.leetcode.Offer;

public class JZ25_2 {
    public ListNode mergeTwoLists(ListNode l1, ListNode l2) {
        if (l1 == null) {
            return l2;
        }
        if (l2 == null) {
            return l1;
        }
        ListNode root = null;

        if (l1.val > l2.val) {
            root = l2;
            root.next = mergeTwoLists(l1, l2.next);
        } else {
            root = l1;
            root.next = mergeTwoLists(l1.next, l2);
        }
        return root;
    }
}
